package org.demo.warehouse.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.demo.warehouse.common.pojo.Record;
import org.demo.warehouse.common.pojo.RecordVo;
import org.demo.warehouse.common.utils.StatisticCollector;
import org.demo.warehouse.mapper.RecordMapper;
import org.demo.warehouse.service.IRecordService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author zgc
 * @since 2021-12-16
 */
@Service
public class RecordServiceImpl extends ServiceImpl<RecordMapper, Record> implements IRecordService {

    @Autowired
    private RecordMapper recordMapper;

    @Override
    public Map<String, List<Object>> getStatistic(Integer type) {
        return recordMapper.statistic(type).stream().collect(StatisticCollector.getInstance());
    }

    @Override
    public <E extends IPage<RecordVo>> E pageVo(E page, QueryWrapper<Record> wrapper) {
        return recordMapper.selectPageVo(page, wrapper);
    }
}
